<?php

namespace app\api\model;

use app\common\model\BaseModel;
use app\common\model\SurveyQuestion as SurveyQuestionModel;
use app\common\model\SurveyOption as SurveyOptionModel;
/**
 * 问卷选项模型
 * Class SurveyOption
 * @package app\store\model
 */
class SurveyOption extends SurveyOptionModel
{
    protected $name = 'survey_option';
    
    /**
     * 获取指定问题的选项列表
     * @param int $questionId
     * @return array
     */
    public function getOptionsByQuestionId($questionId)
    {
        return $this->where('question_id', $questionId)
                    ->where('is_delete', 0)
                    ->order('sort', 'asc')
                    ->select()
                    ->toArray();
    }
    public function add($data)
    {
        $data['wxapp_id'] = self::$wxapp_id;
        // 插入记录
        return $this->allowField(true)->save($data);
    }
}